package com.sicheng.datastruct.tree.基础图论.拓扑序列;

import java.util.*;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/5/12 16:15
 */
public class 邻接表优化 {
    static Map<Integer, Set<Integer>> g;
    static int[] st;//存储入度
    static ArrayList<Integer> res;

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        st = new int[n + 1];
        res = new ArrayList<>();
        g = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            st[y]++;
            Set<Integer> set = g.computeIfAbsent(x, k -> new HashSet<>());
            set.add(y);
        }

        ArrayDeque<Integer> deque = new ArrayDeque<>();
        for (int i = 1; i <= n; i++) {
            if (st[i] == 0)
                deque.offer(i);
        }
        while (!deque.isEmpty()) {
            int head = deque.poll();
            res.add(head);
            Set<Integer> set = g.remove(head);
            if (set != null)
                for (int j : set) {
                    st[j]--;
                    if (st[j] == 0) {
                        deque.offer(j);
                    }
                }
        }
        if (res.size() < n) {
            System.out.println("-1");

        } else
            for (int re : res) {
                System.out.print(re + " ");
            }
    }
}
